<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="../../vue.js"></script>
    <title>Document</title>
    <style>
      .box {
        width: 200px;
        height: 200px;
        margin-top: 10px;
      }
    </style>
  </head>
  <body>
    <!-- vue指令：带有v-前缀的特殊的模板上的属性 -->

    <!-- 非数字的属性值要加引号 -->
    <div id="app">
      <!-- 写法一、字符串 -->
      <div class="box" :style="`background:${isblue?'blue':'red'}`"></div>
      <!-- 写法二、对象 (推荐用)-->
      <div class="box" :style="{background:isblue?'blue':'red'}"></div>
      <!-- 写法三、数组(内部可以写多个对象) -->
      <div class="box" :style="[{background:isblue?'blue':'red'}]"></div>
      <div class="box" :style="[style1,style2]">cccc</div>
    </div>
    <script>
      const vm = new Vue({
        el: '#app',
        data() {
          return {
            isblue: true,
            style1: {
              border: '1px solid black',
            },
            style2: {
              color: 'pink',
            },
          };
        },
      });
    </script>
  </body>
</html>
